package DEEPERsource.DEEPERsource.source.machinelearning.kernel;

import weka.core.Instance;
import machinelearning.features.DepFeatureBuilder;
import machinelearning.features.FeatureBuilder;
import deeper.Interaction;

public class SimpleSyntacticKernel implements Kernel<Interaction> {

	public double compute(Interaction i1, Interaction i2) {
		if(i1.depPath == null || i2.depPath == null)
			return 0;
		FeatureBuilder fb = new DepFeatureBuilder();
		Instance inst1 = fb.getFeatureVector(i1);
		double[] vector1 = inst1.toDoubleArray();
		Instance inst2 = fb.getFeatureVector(i2);
		double[] vector2 = inst2.toDoubleArray();
		Kernel<double[]> poly = new PolynomialKernel();
		((PolynomialKernel)poly).degree = 6;
		((PolynomialKernel)poly).gamma = 1.0/vector1.length;
		return poly.compute(vector1, vector2);
	}

}
